const mysql = require('mysql2')
const {
  MYSQL_HOST,
  MYSQL_PORT,
  MYSQL_PWD,
  MYSQL_USER_NAME,
  MYSQL_DATA_BASE
} = require('./config')
// 数据库池连接


const connects = mysql.createPool({
  host: MYSQL_HOST,
  port: MYSQL_PORT,
  user: MYSQL_USER_NAME,
  password: MYSQL_PWD,
  database: MYSQL_DATA_BASE,

})
connects.getConnection((err, conn) => {
  conn.connect(err => {
    if (err) {
      console.log('连接失败');
    } else {
      console.log('数据库连接成功');
    }
  })
})
module.exports = connects.promise()